package com.smh.a15exerciseDemo2;

public class MyThread extends Thread {
    static int count = 100;

    @Override
    public void run() {
        while (true) {
            synchronized (MyThread.class) {
                if (count == 10) {
                    break;
                } else {
                    try {
                        Thread.sleep(10);
                    } catch (InterruptedException e) {
                        throw new RuntimeException(e);
                    }
                    count--;
                    System.out.println(Thread.currentThread().getName() + "@还剩" + count + "个礼物");
                }
            }
        }

    }
}
